<?php

function get_lang(){
	$language = '';
	$CI =& get_instance();
	$CI->load->library('user_agent');
	if ($CI->session->userdata('language') != '') {
		return $CI->session->userdata('language');
	}elseif($CI->agent->accept_lang('pt')){
		return 'pt';
	} elseif($CI->agent->accept_lang('en')){		
		return 'en';
	} elseif($CI->agent->accept_lang('es')){
		return 'es';
	}else{
		return 'en';
	}
}